package com.roy.galaxy.rest;

import com.roy.galaxy.helper.ServiceLocator;
import com.roy.galaxy.algorithm.LogUtil;
import com.xiaobao.scpbusiness.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by mc on 18/4/10.
 */
@RestController
//@RequestMapping(value = "/idGenerator")
public class IdGeneratorRest {

    @Resource(name = "helloService")
    private HelloService helloService;

    /**
     * 获取id
     * @param bizId
     * @return
     */
    @PostMapping(value = "/getId")
    public Long getId(Integer bizId){
        try{
            return ServiceLocator.getIdGeneratorFacade().getId(bizId);
        }catch (Exception e){
            LogUtil.getDefaultLog().error("IdGeneratorRest.getId#error:{}",e.getMessage());
            return null;
        }
    }



    @GetMapping(value = "/hiRpc")
    public String hiRpc() {
        return helloService.hi();
    }
}
